package com.yun.many.spec.vo;

import com.yun.many.spec.exception.BusinessException;
import com.yun.many.spec.utils.RequestUtils;

import java.io.Serializable;

public interface IResult<T> extends Serializable {
    String getCode();

    String getMsg();

    T getData();

    boolean isSuccess();

    default String traceId() {
        return RequestUtils.getTraceId();
    }

    default void assertSuccess() {
        if (isSuccess()) {
            return;
        }
        throw new BusinessException(getCode(), getMsg());
    }
}
